(function(window,$,undefined){var _block_namespaces_=window._block_namespaces_||(window._block_namespaces_={});var name="block27004";var block27004=_block_namespaces_[name]||(_block_namespaces_[name]={});var options={};$.extend(block27004,{"init":init,"module_init":module_init});function init(nodeObj){if(!!!nodeObj)return;$.extend(options,nodeObj);options.$selector=$("div[data-settingid\x3d"+options.settingId+"]");if(options.state=="frontend")options.prodId=$("#productInfo input[name\x3did]").val()|| "";else{var grandParentDocument=window.parent.parent.document;var element=$(grandParentDocument).find("#product\\.encodePkId");options.prodId=element.val()||""}fetchVideoList();$(window).resize(throttle(function(){setVideoItemCoverSize()},250))}function module_init(){setVideoItemCoverSize()}function fetchVideoList(page){var ajaxConfig={url:"/phoenix2/composite/product/related/video/list/info",method:"get",data:{page:page||1,prodId:options.prodId,limit:8},success:function(res){if(res.code==2E5&&res.data&& res.data.list&&res.data.list.length>0){formatListDom(res.data.list);setVideoItemCoverSize();if(options.$selector.find(".block_27004_video_pagination .b_27004_p_content .b_b66_page_item").length==0){let obj={total:res.data.totalRow,currentPage:res.data.totalPage};setPagination(obj)}}else{options.$selector.find(".block_27004_video_list_content").html("");options.$selector.find(".block_27004_video_list_content").hide();options.$selector.find(".block_27004_no_video_data").css("display","flex")}},error:function(){options.$selector.find(".block_27004_video_list_content").html(""); options.$selector.find(".block_27004_video_list_content").hide();options.$selector.find(".block_27004_no_video_data").css("display","flex")}};if(options.state=="frontend")ajaxConfig.beforeSend=function(xhr){xhr.setRequestHeader("anony","Y")};else{var authorization="";if(window.parent&&window.parent.location.search&&parseUrlParams(window.parent.location.search))authorization=parseUrlParams(window.parent.location.search)["Authorization"];ajaxConfig.beforeSend=function(xhr){xhr.setRequestHeader("Authorization", authorization)}}$.ajax(ajaxConfig)}function parseUrlParams(url){const params={};const urlParts=url.split("?");if(urlParts.length>1){const queryString=urlParts[1];const paramPairs=queryString.split("\x26");paramPairs.forEach(pair=>{const [key,value]=pair.split("\x3d");params[key]=decodeURIComponent(value)})}return params}function setPagination(pageData){var totalPages=Math.ceil(pageData.total/8);if(totalPages<=1)return;var html="";for(let i=0;itotalPages?true:false;currentPage=Math.min(totalPages,currentPage)}else{pageReturnFlag=false;currentPage=pageInfo}if(pageReturnFlag)return;options.$selector.find(".block_27004_video_pagination .b_27004_p_content .b_b66_page_item").removeClass("page_active");options.$selector.find(".block_27004_video_pagination .b_27004_p_content .b_b66_page_item").each(function(){if(currentPage== $(this).attr("data-page"))$(this).addClass("page_active")});fetchVideoList(currentPage)})}function setVideoItemCoverSize(){if(options.$selector.find(".block_27004_video_item").length>0){var blockWidth=options.$selector.find(".block27004").width();if(blockWidth>0&&blockWidth<=800)options.$selector.find(".block_27004_video_item").css("width","calc(50% - 10px)");else if(blockWidth>800)options.$selector.find(".block_27004_video_item").css("width","calc(25% - 10px)");var itemWidth=options.$selector.find(".block_27004_video_item:first-of-type").width(); if(itemWidth<=0)return;var itemHeight=itemWidth*(9/16);options.$selector.find(".block_27004_video_item .block_27004_v_cover").height(itemHeight);var playIconSize=(itemWidth*.1/32).toFixed(2)<1?1:(itemWidth*.1/32).toFixed(2);options.$selector.find(".block_27004_video_item .block_27004_v_cover .block_27004_v_play_icon").css("transform","translate(-50%, -50%) scale("+playIconSize+")")}}function handleClickOutside(event){event.stopPropagation();if(event.target.className=="block_27004_video_detail_popup"){options.$selector.find(".block_27004_video_detail_popup").hide(); options.$selector.find(".block_27004_video_detail_popup .block_27004_video_detail_content .block_27004_video_detail_content_left").html("");options.$selector.find(".block_27004_video_detail_popup .block_27004_video_detail_content .block_27004_video_detail_content_right").html("");options.$selector.find(".block_27004_video_detail_popup").off("click",handleClickOutside);options.$selector.find(".block_27004_video_detail_popup .block_27004_video_detail_content .block_27004_video_detail_content_close").off("click", bindClosePopup)}}function setHtmlAndBind(data){var leftHtml="";var rightHtml="";if(data.isThirdParty)leftHtml='\x3ciframe frameborder\x3d"0" src\x3d"'+data.video_url+'" allowfullscreen\x3d"true" webkitallowfullscreen\x3d"true" mozallowfullscreen\x3d"true" oallowfullscreen\x3d"true" msallowfullscreen\x3d"true"\x3e\x3c/iframe\x3e';else{var isM3u8Video=Boolean(data.video_url.indexOf("mediaType\x3dm3u8")>-1);var ua=navigator.userAgent.toLowerCase();if(ua.match(/MicroMessenger/i)=="micromessenger")leftHtml= '\x3cvideo class\x3d"" controls style\x3d"width: 100%;height: 100%;" data-setup\x3d"{}" preload\x3d"auto"\x3e'+'\x3csource src\x3d"'+data.video_url+'" type\x3d"video/mp4"\x3e\x3c/video\x3e';else if(isM3u8Video)leftHtml='\x3cvideo class\x3d"" controls style\x3d"width: 100%;height: 100%;" data-setup\x3d"{}" preload\x3d"auto"\x3e'+'\x3csource src\x3d"'+data.video_url+'" type\x3d"application/x-mpegurl"\x3e\x3c/video\x3e';else leftHtml='\x3cvideo class\x3d"" controls style\x3d"width: 100%;height: 100%;" data-setup\x3d"{}" preload\x3d"auto"\x3e'+ '\x3csource src\x3d"'+data.video_url+'" type\x3d"video/mp4"\x3e\x3c/video\x3e'}options.$selector.find(".block_27004_video_detail_popup .block_27004_video_detail_content .block_27004_video_detail_content_left").html(leftHtml);var prodHtml="";for(var i=0;i